﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Linq;
using Engine;
using Engine.Graphics;
using Engine.Media;
using GameEntitySystem;
using TemplatesDatabase;
using XmlUtilities;

namespace Game
{
    public class TestLoader : ModLoader
    {
        public static class ModItemManger
        {
            public static bool IsVisibleLogInScreen;

            public static void Load(ValuesDictionary valuesDictionary)
            {
                IsVisibleLogInScreen = valuesDictionary.GetValue("IsVisibleLogInScreen", defaultValue: false);
            }

            public static void Save(ValuesDictionary valuesDictionary)
            {
                valuesDictionary.SetValue("IsVisibleLogInScreen", IsVisibleLogInScreen);
            }
        }

        public class LogsData
        {
            public string Content;

            public Color Color;
        }

        public SubsystemCreatureSpawn m_subsystemCreatureSpawn;

        public SubsystemGameInfo m_subsystemGameInfo;

        public SubsystemSpawn m_subsystemSpawn;

        public SubsystemTerrain m_subsystemTerrain;

        public SubsystemTime m_subsystemTime;

        public SubsystemSky m_subsystemSky;

        public SubsystemBodies m_subsystemBodies;

        public SubsystemGameWidgets m_subsystemViews;

        public List<SubsystemCreatureSpawn.CreatureType> m_creatureTypes;

        public Random m_random = new Random();

        public SubsystemTime m_subsystemtime;

        public static List<LogsData> m_logsList = new List<LogsData>();

        public static ValuesDictionary m_valuesDictionary = new ValuesDictionary();

        public override void __ModInitialize()
        {
            ModsManager.RegisterHook("InitializeCreatureTypes", this);
            ModsManager.RegisterHook("OnModelRendererDrawExtra", this);
            ModsManager.RegisterHook("OnModalPanelWidgetSet", this);
            ModsManager.RegisterHook("OnLoadingStart", this);
            ModsManager.RegisterHook("OnLoadingFinished", this);
            ModsManager.RegisterHook("OnXdbLoad", this);
            ModsManager.RegisterHook("GuiUpdate", this);
        }

        public override void GuiUpdate(ComponentGui componentGui)
        {
        }

        public override void SaveSettings(XElement xElement)
        {
            ModItemManger.Save(m_valuesDictionary);
            XElement xElement2 = new XElement("Datas");
            xElement.Add(xElement2);
            m_valuesDictionary.Save(xElement2);
        }

        public override void LoadSettings(XElement xElement)
        {
            XElement overridesNode = XmlUtils.FindChildElement(xElement, "Datas", throwIfNotFound: true);
            m_valuesDictionary.ApplyOverrides(overridesNode);
            ModItemManger.Load(m_valuesDictionary);
        }

        public override void OnLoadingStart(List<Action> actions)
        {
            base.OnLoadingStart(actions);
            actions.Add(delegate
            {
            });
        }

        public override void OnXdbLoad(XElement xElement)
        {
            if (!ModsManager.GetModEntity("scmod mod", out var modEntity))
            {
                return;
            }

            modEntity.GetFiles(".netxdb", delegate (string filename, Stream stream)
            {
                XElement xElement2 = XmlUtils.LoadXmlFromStream(stream, Encoding.UTF8, throwOnError: true);
                if (xElement2 != null)
                {
                    foreach (XElement item in xElement2.Descendants("XdbContent"))
                    {
                        if (ModsManager.FindElementByGuid(xElement, XmlUtils.GetAttributeValue<string>(item, "Guid"), out var elementout))
                        {
                            elementout.Add(item.Elements());
                        }
                    }
                }
            });
        }

        public List<Entity> SpawnCreatures(SubsystemCreatureSpawn.CreatureType creatureType, string templateName, Point3 point, int count)
        {
            return m_subsystemCreatureSpawn.SpawnCreatures(creatureType, templateName, point, count);
        }

        public override void OnModelRendererDrawExtra(SubsystemModelsRenderer modelsRenderer, ComponentModel componentModel, Camera camera, float? alphaThreshold)
        {
            ComponentBody componentBody = componentModel.Entity.FindComponent<ComponentBody>();
            if (componentBody == null || componentModel == null || componentBody.ParentBody != null)
            {
                return;
            }

            ComponentCreature componentCreature = componentModel.Entity.FindComponent<ComponentCreature>();
            ComponentHealth componentHealth = componentModel.Entity.FindComponent<ComponentHealth>();
            if (componentHealth != null)
            {
                Vector3 vector = Vector3.Transform(componentCreature.ComponentBody.Position + 1.2f * Vector3.UnitY * componentCreature.ComponentBody.BoxSize.Y, camera.ViewMatrix);
                if (vector.Z < 0f && Color.Lerp(Color.White, Color.Transparent, MathUtils.Saturate((vector.Length() - 4f) / 3f)).A > 8)
                {
                    float num = 15f;
                    Color color = Color.White * new Color(num, num, num, 255f);
                    Color color2 = new Color(1f - componentHealth.Health, componentHealth.Health, 0f) * new Color(num, num, num);
                    Vector3 vector2 = vector - Vector3.UnitY * 0.05f;
                    Vector3 right = Vector3.TransformNormal(0.005f * Vector3.Normalize(Vector3.Cross(camera.ViewDirection, Vector3.UnitY)), camera.ViewMatrix);
                    Vector3 down = Vector3.TransformNormal(-0.005f * Vector3.UnitY, camera.ViewMatrix);
                    BitmapFont bitmapFont = LabelWidget.BitmapFont;
                    FontBatch3D fontBatch3D = modelsRenderer.PrimitivesRenderer.FontBatch(bitmapFont, 1, DepthStencilState.DepthRead, RasterizerState.CullNoneScissor, BlendState.AlphaBlend, SamplerState.LinearClamp);
                    FlatBatch3D flatBatch3D = modelsRenderer.PrimitivesRenderer.FlatBatch(1, DepthStencilState.DepthRead, RasterizerState.CullNoneScissor, BlendState.AlphaBlend);
                    Vector3 vector3 = vector2 + new Vector3(-0.51f, 0.01f, 0f);
                    Vector3 vector4 = vector2 + new Vector3(0.51f, 0.01f, 0f);
                    Vector3 vector5 = vector2 + new Vector3(0.51f, -0.13f, 0f);
                    Vector3 vector6 = vector2 + new Vector3(-0.51f, -0.13f, 0f);
                    Vector3 p = vector2 + new Vector3(-0.5f, 0f, 0f);
                    Vector3 p2 = vector2 + new Vector3(-0.5f + componentHealth.Health, 0f, 0f);
                    Vector3 p3 = vector2 + new Vector3(-0.5f + componentHealth.Health, -0.12f, 0f);
                    Vector3 p4 = vector2 + new Vector3(-0.5f, -0.12f, 0f);
                    flatBatch3D.QueueLine(vector3, vector4, color);
                    flatBatch3D.QueueLine(vector4, vector5, color);
                    flatBatch3D.QueueLine(vector5, vector6, color);
                    flatBatch3D.QueueLine(vector6, vector3, color);
                    Vector3 position = vector2 + Vector3.UnitY * 0.3f;
                    string text = $"生命值:{(int)(componentHealth.Health * componentHealth.AttackResilience)}/{(int)componentHealth.AttackResilience}";
                    fontBatch3D.QueueText(componentCreature.DisplayName, position, right, down, color, TextAnchor.HorizontalCenter);
                    fontBatch3D.QueueText(text, position, right, down, Color.Green, TextAnchor.HorizontalCenter | TextAnchor.Bottom);
                    flatBatch3D.QueueQuad(p, p2, p3, p4, color2);
                }
            }
        }

        public override void InitializeCreatureTypes(SubsystemCreatureSpawn spawn, List<SubsystemCreatureSpawn.CreatureType> creatureTypes)
        {
            m_creatureTypes = creatureTypes;
            m_subsystemCreatureSpawn = spawn;
            m_subsystemGameInfo = spawn.Project.FindSubsystem<SubsystemGameInfo>(throwOnError: true);
            m_subsystemSpawn = spawn.Project.FindSubsystem<SubsystemSpawn>(throwOnError: true);
            m_subsystemTerrain = spawn.Project.FindSubsystem<SubsystemTerrain>(throwOnError: true);
            m_subsystemTime = spawn.Project.FindSubsystem<SubsystemTime>(throwOnError: true);
            m_subsystemSky = spawn.Project.FindSubsystem<SubsystemSky>(throwOnError: true);
            m_subsystemBodies = spawn.Project.FindSubsystem<SubsystemBodies>(throwOnError: true);
            m_subsystemViews = spawn.Project.FindSubsystem<SubsystemGameWidgets>(throwOnError: true);
            base.InitializeCreatureTypes(spawn, m_creatureTypes);
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Pandas", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num97 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity22 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num98 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num97 > 20f && humidity22 > 8 && point.Y < 80 && (num98 == 8 || num98 == 2)) ? 0.25f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Pandas", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Sheep", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num95 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num96 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num95 > 8f && (num96 == 7 || num96 == 8 || num96 == 2 || num96 == 3 || num96 == 61)) ? 0.25f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Sheep", point, 2).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Shortbear", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num93 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature21 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity21 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num94 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num93 > 40f && humidity21 >= 4 && temperature21 >= 8 && point.Y < 109 && (num94 == 8 || num94 == 2 || num94 == 3)) ? 0.18f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Shortbear", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Sabretooth", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num91 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature20 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity20 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num92 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num91 > 42f && humidity20 >= 4 && temperature20 >= 8 && point.Y < 110 && (num92 == 8 || num92 == 2 || num92 == 3)) ? 0.18f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Sabretooth", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Snake", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num89 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature19 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity19 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num90 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num89 > 40f && temperature19 > 8 && humidity19 > 7 && point.Y < 75 && (num90 == 8 || num90 == 2 || num90 == 3)) ? 0.18f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Snake", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Cave_Spider", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int num88 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num88 == 3 || num88 == 67 || num88 == 4 || num88 == 66 || num88 == 2 || num88 == 7) ? 0.55f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Cave_Spider", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Crocodile", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num87 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity18 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature18 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    return (num87 > 20f && humidity18 >= 4 && temperature18 >= 7) ? 0.55f : 0f;
                },
                SpawnFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    string templateName2 = "Crocodile";
                    return SpawnCreatures(creatureType, templateName2, point, m_random.Int(1, 3)).Count;
                }
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("DinanourBird", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num85 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num86 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num85 > 8f && (num86 == 7 || num86 == 8 || num86 == 2 || num86 == 3 || num86 == 61)) ? 0.025f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "DinanourBird", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Fox", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature17 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num84 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature17 < 7 && point.Y < 80 && (num84 == 8 || num84 == 2 || num84 == 3 || num84 == 62)) ? 0.25f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Fox", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Hippo", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num83 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity17 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature16 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    return (num83 > 20f && humidity17 >= 4 && temperature16 >= 7) ? 0.5f : 0f;
                },
                SpawnFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    string templateName = "Hippo";
                    return SpawnCreatures(creatureType, templateName, point, m_random.Int(1, 3)).Count;
                }
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("WolfKing", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num81 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature15 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity16 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num82 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num81 > 40f && humidity16 > 8 && temperature15 > 8 && point.Y < 100 && (num82 == 8 || num82 == 2 || num82 == 3 || num82 == 7 || num82 == 12)) ? 0.05f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "WolfKing", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num78 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity15 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num79 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num80 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast8 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num78 > 25f && humidity15 >= 8) || (num79 <= 8f && point.Y < 91 && (double)cellLightFast8 <= 7.1)) && (num80 == 8 || num80 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lizard", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("AncientRhino", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num76 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature14 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity14 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num77 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num76 > 40f && temperature14 > 8 && humidity14 > 7 && point.Y < 75 && (num77 == 8 || num77 == 2 || num77 == 3)) ? 0.07f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "AncientRhino", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Mammoth", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num74 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity13 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num75 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num74 > 30f && humidity13 > 8 && point.Y < 83 && (num75 == 8 || num75 == 2)) ? 0.018f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Mammoth", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("dragon", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num72 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature13 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity12 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num73 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num72 > 40f && temperature13 > 8 && humidity12 > 7 && point.Y < 75 && (num73 == 8 || num73 == 2 || num73 == 3)) ? 0.05f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "dragon", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("konxi", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num70 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature12 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity11 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num71 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num70 > 40f && temperature12 > 8 && humidity11 > 7 && point.Y < 75 && (num71 == 8 || num71 == 2 || num71 == 3)) ? 0.05f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "konxi", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Chicken", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature11 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num69 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature11 < 7 && point.Y < 80 && (num69 == 8 || num69 == 2 || num69 == 3 || num69 == 62)) ? 0.15f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Chicken", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Yazi", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature10 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num68 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature10 < 7 && point.Y < 80 && (num68 == 8 || num68 == 2 || num68 == 3 || num68 == 62)) ? 0.15f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Yazi", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Rabbit", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature9 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num67 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature9 < 7 && point.Y < 80 && (num67 == 8 || num67 == 2 || num67 == 3 || num67 == 62)) ? 0.15f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Rabbit", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Xiezi", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num65 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature8 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num66 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num65 > 40f && temperature8 > 8 && point.Y < 80 && (num66 == 8 || num66 == 2 || num66 == 3 || num66 == 7)) ? 0.08f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Xiezi", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Yin", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num63 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity10 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature7 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num64 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight3 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (humidity10 > 8 && temperature7 > 4 && num63 > 30f && point.Y >= topHeight3 && (BlocksManager.Blocks[num64] is LeavesBlock || num64 == 18 || num64 == 8 || num64 == 2)) ? 0.05f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Yin", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Lama1", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num61 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature6 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num62 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num61 > 20f && temperature6 > 7 && point.Y < 120 && (num62 == 8 || num62 == 2 || num62 == 3 || num62 == 7)) ? 0.08f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lama1", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Pig1", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature5 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num60 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature5 < 7 && point.Y < 80 && (num60 == 8 || num60 == 2 || num60 == 3 || num60 == 62)) ? 0.15f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Pig1", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("LongSnoutedBoar", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature4 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num59 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature4 < 7 && point.Y < 80 && (num59 == 8 || num59 == 2 || num59 == 3 || num59 == 62)) ? 0.27f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "LongSnoutedBoar", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Turtle", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num57 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int num58 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight2 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (num57 > -100f && num57 < 39f && point.Y >= topHeight2 && (num58 == 18 || num58 == 7 || num58 == 6 || num58 == 62)) ? 0.09f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Turtle", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Qier", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num55 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature3 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num56 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num55 > 40f && temperature3 < 2 && point.Y < 90 && (num56 == 8 || num56 == 2 || num56 == 3 || num56 == 7 || num56 == 62)) ? 0.25f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Qier", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Kangroo", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num53 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num54 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num53 > 8f && (num54 == 7 || num54 == 8 || num54 == 2 || num54 == 3 || num54 == 61)) ? 0.025f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Kangroo", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Kzl", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num51 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num52 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num51 > 8f && (num52 == 7 || num52 == 8 || num52 == 2 || num52 == 3 || num52 == 61)) ? 0.2f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Kzl", point, 3).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Yahoo", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num49 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num50 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num49 > 20f && (num50 == 7 || num50 == 8 || num50 == 2 || num50 == 3 || num50 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Yahoo", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Pirate", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num47 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int num48 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (num47 > -100f && num47 < 39f && point.Y >= topHeight && (num48 == 18 || num48 == 7 || num48 == 6 || num48 == 62)) ? 0.18f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Pirate", point, 1).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Hobo", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num45 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num46 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num45 > 20f && (num46 == 7 || num46 == 8 || num46 == 2 || num46 == 3 || num46 == 61)) ? 0.132f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hobo", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Yahoogirl", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num43 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num44 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num43 > 20f && (num44 == 7 || num44 == 8 || num44 == 2 || num44 == 3 || num44 == 61)) ? 0.18f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Yahoogirl", point, 2).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Savage", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num41 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num42 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num41 > 20f && (num42 == 7 || num42 == 8 || num42 == 2 || num42 == 3 || num42 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Savage", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("YahooTiger", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num39 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num40 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num39 > 20f && (num40 == 7 || num40 == 8 || num40 == 2 || num40 == 3 || num40 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "YahooTiger", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("YahooBear", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num37 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num38 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num37 > 20f && (num38 == 7 || num38 == 8 || num38 == 2 || num38 == 3 || num38 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "YahooBear", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("YahooWolf", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num35 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num36 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num35 > 20f && (num36 == 7 || num36 == 8 || num36 == 2 || num36 == 3 || num36 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "YahooWolf", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num32 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity9 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num33 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num34 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast7 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num32 > 25f && humidity9 >= 8) || (num33 <= 8f && point.Y < 91 && (double)cellLightFast7 <= 7.2)) && (num34 == 8 || num34 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Shooter", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Villiger", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num30 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num31 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num30 > 20f && (num31 == 7 || num31 == 8 || num31 == 2 || num31 == 3 || num31 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Villiger", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Villigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    int temperature2 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num29 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (temperature2 < 7 && point.Y < 80 && (num29 == 8 || num29 == 2 || num29 == 3 || num29 == 62)) ? 0.25f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Villigers", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num26 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity8 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num27 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num28 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast6 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num26 > 25f && humidity8 >= 8) || (num27 <= 8f && point.Y < 91 && (double)cellLightFast6 <= 7.2)) && (num28 == 8 || num28 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "ptzombie", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num23 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity7 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num24 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num25 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast5 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num23 > 25f && humidity7 >= 8) || (num24 <= 8f && point.Y < 91 && (double)cellLightFast5 <= 7.2)) && (num25 == 8 || num25 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "xbzombie", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num20 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity6 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num21 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num22 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast4 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num20 > 25f && humidity6 >= 8) || (num21 <= 8f && point.Y < 91 && (double)cellLightFast4 <= 7.2)) && (num22 == 8 || num22 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "edman", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num17 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity5 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num18 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num19 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast3 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num17 > 25f && humidity5 >= 8) || (num18 <= 8f && point.Y < 91 && (double)cellLightFast3 <= 7.2)) && (num19 == 8 || num19 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "shike", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("shike", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num15 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity4 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num16 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num15 > 20f && temperature > 8 && humidity4 < 8 && point.Y < 80 && num16 == 7) ? 0.08f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "shike", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num12 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity3 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num13 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num14 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast2 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num12 > 25f && humidity3 >= 8) || (num13 <= 8f && point.Y < 91 && (double)cellLightFast2 <= 7.2)) && (num14 == 8 || num14 == 2))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "zombie", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    float num10 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity2 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num11 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num10 > 40f && humidity2 >= 8 && point.Y < 100 && (num11 == 8 || num11 == 2)) ? 0.075f : 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Direwolf", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num7 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num8 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num9 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num7 > 20f && humidity >= 8) || (num8 <= 8f && point.Y < 90 && cellLightFast <= 7)) && (num9 == 8 || num9 == 2))
                        {
                            return 2f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Direwolf", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Ysr", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num5 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num6 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num5 > 20f && (num6 == 7 || num6 == 8 || num6 == 2 || num6 == 3 || num6 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Ysr", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Ysyr", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num3 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num4 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num3 > 20f && (num4 == 7 || num4 == 8 || num4 == 2 || num4 == 3 || num4 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Ysyr", point, m_random.Int(1, 1)).Count
            });
            m_creatureTypes.Add(new SubsystemCreatureSpawn.CreatureType("Blymr", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point)
                {
                    if (m_subsystemSky.SkyLightIntensity > 0.1f)
                    {
                        float num = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int num2 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        return (num > 20f && (num2 == 7 || num2 == 8 || num2 == 2 || num2 == 3 || num2 == 61)) ? 0.134f : 0f;
                    }

                    return 0f;
                },
                SpawnFunction = (SubsystemCreatureSpawn.CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Blymr", point, m_random.Int(1, 1)).Count
            });
        }
    }
}